
<%@page import="java.util.List"%>
<%@page import="com.search.dynamics.samples.spring.controller.Document"%>
<%@page import="com.search.dynamics.samples.spring.controller.WebConstants"%>
<html>

<head>
	<link rel="stylesheet" type="text/css" href="css/search_dynamics.css" />
  	<script type='text/javascript' src='<%=request.getContextPath()%>/pages/dwr/interface/search.js'></script>
  	<script type='text/javascript' src='<%=request.getContextPath()%>/pages/dwr/engine.js'></script>
  	<script type='text/javascript' src='<%=request.getContextPath()%>/pages/dwr/util.js'></script>
  
  	<script type="text/javascript">
  	var resultDiv;
	function getHotelDetails(id){
		resultDiv=id;
		search.getHotelDetails(id, renderHotelDetails);
	}

	function renderHotelDetails(response){
		var detailsHTML="<b>Name : </b>"+response.hotel_name+
						"<br><b>Address : </b>"+response.hotel_address+
						"<br><b>Opening Hours : </b>"+response.hotel_hours+
						"<br><b>Bar Available : </b>"+response.hotel_is_bar+
						"<br><b>Speciality : </b>"+response.hotel_specialty;
		DWRUtil.setValue('message'+resultDiv, detailsHTML);
		
	}
  
  </script>
</head>

<body>

<form action="/search.solr">
<table cellpadding="0" cellspacing="0" width="100%" class="formbackground">
	<tr>
		<td width="100%" align="center" class="highlightMessage">SearchDynamics</td>
	</tr>
	<tr>
		<td width="100%" align="center" class="heading">
			<label>What :</label><input type="text" name="what" id="what" class="textBoxStyle"/>
			<label>Where :</label><input type="text" name="where" id="where" class="textBoxStyle"/>
			<input type="hidden" name="method" id="method" value="search">
			<input type="submit" class="buttonStyle"/>
		</td>
	</tr>

</table>
	<br>

	<table cellpadding="0" cellspacing="0" width="100%" class="searchResult">
	<%String solrSearchResultMessage=(String) request.getAttribute(WebConstants.SOLR_SEARCH_RESULT_MESSAGE);%>
	<tr>
		<td width="20%"  class="buttonpane" colspan="2"><b><%=solrSearchResultMessage%></b></td>
	</tr>	
	<%
		List<Document> solrSearchResult=(List<Document>)request.getAttribute(WebConstants.SOLR_SEARCH_RESULT); 
		if(solrSearchResult != null && solrSearchResult.size() > 0) {
			for(Document result:solrSearchResult) {%>
			<tr>
				<td width="20%" class="userheader"><a href="javascript:getHotelDetails(<%=result.getDocId()%>);">Business/Person</a></td>
				<td width="80%" ><%=result.getDocName()%></td>
			</tr>
			<tr>
				<td width="20%"  class="userheader"><b>ID</b></td>
				<td width="80%" ><%=result.getDocId()%></td>
			</tr>
			<tr>
				<td width="20%" class="userheader"><b>Place </b></td>
				<td width="80%" ><%=result.getDocPlace()%></td>
			</tr>
			<tr>	
				<td width="20%" class="userheader"><b>Category </b></td>
				<td width="80%" ><%=result.getDocCategory()%></td>
			</tr>
			<tr>	
				<td width="20%" class="userheader"><b>Description </b></td>
				<td width="80%" ><%=result.getDocDesc() %></td>
			</tr>
			<tr>	
				<td width="20%" class="userheader"><b>Key Words </b></td>
				<td width="80%" ><%=result.getDocKeyWords() %></td>
			</tr>
			<tr>	
				<td width="20%" class="userheader">Type</td>
				<td width="80%" ><%=result.getDocType() %></td>
			</tr>
			<tr>	
				<td width="100%" colspan="2">
					<span id="message<%=result.getDocId()%>" class="bodybackground" ></span>
				</td>
			</tr>
			<%}
		}
	%>
	</table>

</form>

</body>
</html>